In [9]:
    
%matplotlib inline
import matplotlib.pyplot as plt
plt.style.use('seaborn')
    
In [10]:
    
import os
from urllib.request import urlretrieve
import pandas as pd
URL = 'https://data.seattle.gov/api/views/65db-xm6k/rows.csv?accessType=DOWNLOAD'
def get_fremont_data(filename='Fremont.csv', url=URL):
    if not os.path.exists(filename):
        urlretrieve(url, filename)
    data = pd.read_csv('Fremont.csv', index_col='Date', parse_dates=True)
    data.columns = ('West', 'East')
    data['Total'] = data['West'] + data['East']
    return data
    
In [11]:
    
data = get_fremont_data()
data.head()
    
    Out[11]:
In [12]:
    
from urllib.request import urlretrieve
urlretrieve(URL, 'Fremont.csv')
    
    Out[12]:
In [13]:
    
%matplotlib inline
data.resample('W').sum().plot(); #W stands for weekly, sum the values, and then plot
    
    
In [14]:
    
data.resample('W').sum().plot();
    
    
In [15]:
    
data['Total'] = data['West'] + data['East']
ax = data.resample('D').sum().rolling(365).sum().plot();
ax.set_ylim(0, None);
    
    
In [16]:
    
data.groupby(data.index.time).mean().plot();
    
    
In [17]:
    
pivoted = data.pivot_table('Total', index=data.index.time, columns=data.index.date)
pivoted.iloc[:5, :5]
    
    Out[17]:
In [18]:
    
pivoted.plot(legend=False, alpha=0.01);
    
    
In [ ]: